/**
 * @author Federico Consoli
 *
 * Released under GNU GPLv3 (http://www.gnu.org/licenses/gpl-3.0.txt)
 */


#define cs(x) Connection::char_to_string(x)
#define cus(x) Connection::char_to_uns_short(x)

#include "libreria.h"



int main(int argc, const char * argv[]) {
    if ((argc ==2 && argv[1][1]=='h')) {
        cout << "\nSintax: ./reg_server <ip_reg> <port_reg> \n\n";
        cout << "Parameters are preparatory in order of entry, so you can entry no value\n";
        cout << "Or you can entry only ip_reg or only ip_reg+port_reg etc. etc.\n\n";
        cout << "ip_reg default: 127.0.0.1\n";
        cout << "port_reg default: 40000\n\n";
        return 0;
    }
        
    Registro *reg=NULL;
       
    try{
    
    switch (argc) {
        case 1:
            reg=new Registro;
            break;
        case 2:
            reg=new Registro(cs(argv[1]));
            break;
        case 3:
            reg=new Registro(cs(argv[1]),cus(argv[2]));            
            break;
    }
    
    if(reg!=NULL)
        reg->avvia();
    
    }
     catch (int num_exc){
    Exception_class::exc(num_exc);
     }
    delete reg;
    return 0;
}

